﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http;
using Newtonsoft.Json;
using Model;
using Data.Service;

namespace SYT.Web.WebApi
{
    public class IntelligenceManageAPIController : ApiController
    {
        //保存自动重发
        public bool UpdateAutoResend()
        {
            string parameter1 = HttpContext.Current.Request["data"];

            var data = JsonConvert.DeserializeObject<dynamic>(parameter1);
            string MemberId = data["MemberId"];
            Intelligence_AutoResend autoResend = Intelligence_AutoResendData.GetAutoResend(MemberId);
            autoResend.IsResend = data["open"];//是否自动重发
            autoResend.IsAllProduct = data["AllPro"];//是否按全店重发
            autoResend.IszidingyiProduct = data["customResend"];//是否自定义产品重发
            autoResend.UpdateTime = DateTime.Now;//当前时间      

            return Intelligence_AutoResendData.UpdateAutoResend(autoResend);
        }

        //保存自动评价
        public bool UpdateAutoAppraise()
        {
            string parameter1 = HttpContext.Current.Request["data"];

            var data = JsonConvert.DeserializeObject<dynamic>(parameter1);
            string MemberId = data["MemberId"];
            Intelligence_AutoAppraise autoAppraise = Intelligence_AutoAppraiseData.GetAutoAppraise(MemberId);
            autoAppraise.IsAutoAppraise = data["open"];//是否自动评价
            autoAppraise.AppraiseContents = data["appraiseContents"];//评价
            autoAppraise.UpdateTime = DateTime.Now;//当前时间      

            return Intelligence_AutoAppraiseData.UpdateAutoAppraise(autoAppraise);
        }

         //保存自动橱窗
        public bool UpdateAutoWindow()
        {
            string parameter1 = HttpContext.Current.Request["data"];

            var data = JsonConvert.DeserializeObject<dynamic>(parameter1);
            string MemberId = data["MemberId"];
            Intelligence_AutoWindow autoAppraise = Intelligence_AutoWindowData.GetAutoWindow(MemberId);
            autoAppraise.IsAutoWindow = data["open"];//是否自动橱窗
            autoAppraise.IsAllProduct = data["IsAllProduct"];//橱窗
            autoAppraise.UpdateTime = DateTime.Now;//当前时间      

            return Intelligence_AutoWindowData.UpdateAutoWindow(autoAppraise);
        }

        //保存自动补库存
        public bool UpdateAutoStock()
        {
            string parameter1 = HttpContext.Current.Request["data"];

            var data = JsonConvert.DeserializeObject<dynamic>(parameter1);
            string MemberId = data["MemberId"];
            Intelligence_AutoStock autoAppraise = Intelligence_AutoStockData.GetAutoStock(MemberId);
            autoAppraise.IsAutoStock = data["open"];//是否自动补库存
            autoAppraise.IsAllProduct = data["IsAllProduct"];//是否按全部产品补库存
            autoAppraise.DuanqueNumber = data["DuanqueNumber"];//是否按全部产品补库存
            autoAppraise.AddNumber = data["AddNumber"];//是否按全部产品补库存
            autoAppraise.UpdateTime = DateTime.Now;//当前时间      

            return Intelligence_AutoStockData.UpdateAutoStock(autoAppraise);
        }


        
    }
}